<template>
  <div class="m-b-12" v-if="!!produceTaskBillNo">
    <CellBox title="订单信息" isTop>
      <template #btn>
        <el-link type="primary" @click="pup.state = true">查看工单</el-link>
      </template>
      <FlexBox :margin="2">
        <ElFormItemBox label="协议书号">
          <ElTooltipBox :data="dataInfo.productOrder?.xieYiShuHao" />
        </ElFormItemBox>
        <ElFormItemBox label="生产单号">
          <ElTooltipBox :data="dataInfo.productOrder?.produceTaskBillNo" />
        </ElFormItemBox>
        <ElFormItemBox label="客户名称">
          <ElTooltipBox :data="dataInfo.productOrder?.customerName" />
        </ElFormItemBox>
        <ElFormItemBox label="产品编号">
          <ElTooltipBox :data="dataInfo.productOrder?.productNo" />
        </ElFormItemBox>
        <ElFormItemBox label="产品名称">
          <ElTooltipBox :data="dataInfo.productOrder?.orderProductName" />
        </ElFormItemBox>
        <ElFormItemBox label="产品版本">
          {{ dataInfo.productOrder?.orderProductVersion || '--' }}
        </ElFormItemBox>
        <ElFormItemBox label="印刷版面">
          {{ dataInfo.productOrder?.printingSurface || '--' }}
        </ElFormItemBox>
        <ElFormItemBox label="客户单号">
          {{ dataInfo.productOrder?.customerBillNo || '--' }}
        </ElFormItemBox>
      </FlexBox>
    </CellBox>
    <ElPupBox :pup="pup" isBg>
      <Page :isPup="true" :query="{
        produceTaskBillNo: produceTaskBillNo
      }" />
    </ElPupBox>
  </div>
</template>
<script setup lang="ts">
import Page from '@/views/production/productionOrderNew/details/index.vue'; // 引入逻辑
const { proxy } = getCurrentInstance() as any;
const props = withDefaults(
  defineProps<{
    produceTaskBillNo?: string;//生产单号
  }>(),
  {

  },
);
watch(() => props.produceTaskBillNo, (newVal, oldVal) => {
  getForm();
});
const dataInfo: any = reactive({
  productOrder: {},//产品信息
});
const pup = reactive({
  state: false,
  title: '查看工单',
});
//获取数据
const getForm = async () => {
  if (props.produceTaskBillNo) {
    await proxy.$api.ProductionBusniess.GetMatchPageProduceTaskBills({
      pageIndex: 1,
      pageSize: 1,
      queryDataBaseFiled: 'produceTaskBillNo',
      likeWords: props.produceTaskBillNo,
      isShowCancelBills: false,
      isShowCompleteBills: true,
      produceBillType: 0,
      produceBillState: -1,
      taskProduceState: -1,
      materialState: -1,
      dataBillState: -2,
      beginTime: '',
      endTime: '',
    })
      .then((res: any) => {
        if (res.list?.length > 0) {
          const _row = res.list[0]
          dataInfo.productOrder = _row
          changeBtn(_row)
        }
      })
      .catch(() => {
      });
  }
};
const emit = defineEmits<{
  //fn为父组件引入子组件是定义的子组件事件属性，可随意定义
  (event: 'changeBtn', row: any): void;
}>();
const changeBtn = (row: any) => {
  emit('changeBtn', row);
};
onMounted(() => {
  getForm();
});
</script>
<style scoped lang="scss"></style>
